package com.xiaolin.dao.impl;

import com.xiaolin.bean.Shopp;
import com.xiaolin.dao.BaseDAO;
import com.xiaolin.dao.ShoppDAO;

import java.sql.Connection;
import java.util.List;

public class DigitalDAOImpl extends BaseDAO<Shopp> implements ShoppDAO {
    /**
     * 将Shopp对象添加到数据库中
     *
     * @param conn
     * @param sp
     */
    @Override
    public void insert(Connection conn, Shopp sp) {
        System.out.println("笨蛋，用不到这个方法欧！");
    }

    /**
     * 根据指定id的那么修改一条数码数据
     *
     * @param conn
     * @param sp
     */
    @Override
    public void updateById(Connection conn, Shopp sp) {
        String sql = "UPDATE allshopp SET quantity = ? WHERE id = ? AND type='数码'";
        update(conn, sql,sp.getQuantity(),sp.getId());
    }

    /**
     * @param conn
     * @param id
     * @return
     */
    @Override
    public Shopp getShopp(Connection conn, String id) {
        return null;
    }

    /**
     * 获取所有的商品
     *
     * @param conn
     * @return
     */
    @Override
    public List<Shopp> getAll(Connection conn) {
        String sql = "SELECT * FROM allshopp WHERE type='数码'";
        List<Shopp> list = getForList(conn, sql);
        return list;
    }
}
